<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>输入年份判断改年是平年还是闰年 能够被4整除 
        且不能被100整除 或者 能够被400整除的年份就是闰年 其他的就是平年
    </div>
    <input type="text" id="years">
    <button id="btn">查询</button>
    <script>
        var years = document.getElementById("years");
        var btn = document.getElementById("btn");
        btn.onclick = function () {
            var res = parseInt(years.value);
            if ( ( res % 100 ) == 0) {
                if ( ( res % 400 ) == 0) {
                    window.alert( res + "是闰年");
                } else {
                    window.alert(res + "不是闰年");
                } 
            } else if ( ( res % 4 ) == 0 ) {
                window.alert(res + "是闰年");
            } else {
                window.alert(res + "不是闰年");
            }
            years.value = null;
        }
    </script>
</body>
</html>